
import { Button } from 'antd'
import { useNavigate } from 'react-router-dom'
import './child1.scss'
const Child1 = ({ name, setParentData }) => {
  let Navigate = useNavigate()
  const changeParent = () => {
    setParentData('我是child1数据')
  }
  const changePage = () => {
    Navigate('/Page1?id=22')
  }
  const changePage2 = () => {
    Navigate('/Page2?id=11')
  }
  return (
    <>
      <div className="child1">子组件1:{name}</div>
      <Button type="primary" onClick={changeParent}>子传递数据给父组件</Button>
      <Button type="primary" onClick={changePage}>跳转到page1</Button>
      <Button type="primary" onClick={changePage2}>跳转到page2</Button>
    </>
  )
}

export default Child1